<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div>
    <input id="ipt" type="text">
    <span id="txt"></span>
  </div>

  <script>

    let ipt = document.getElementById('ipt');
    let txt = document.getElementById("txt");

    var userinfo = {
      name: ''
    }

    Object.defineProperty(userinfo, 'name', {
      get() {
        console.log('usuerinfo.name get...')
        return this._val;
      },
      set(newval) {
        txt.innerHTML = newval;
        this._val = newval;
      }
    })

    ipt.addEventListener('input', (e) => {
      userinfo.name = e.target.value;
    })

  </script>

</body>

</html>